package com.example.ch5_1intent;

import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;

public class MainActivity extends AppCompatActivity {

    private Button btn;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        btn = findViewById(R.id.btn);
        btn.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                //隐式跳转
//                startActivityByAction();
                //使用date和type的方式启动activity
                startActivityByDate();
            }
        });




    }

    private void startActivityByDate() {
        //实例化intent
        Intent intent = new Intent();
        //设置跳转意图
        //定义uri特征
        Uri uri = Uri.parse("beauty://china:5000/yyh");
        intent.setDataAndType(uri,"sjz/sd");
        //启动跳转
        startActivity(intent);
    }

    private void startActivityByAction() {
        //实例化intent
        Intent intent = new Intent();
        //设置跳转意图
        intent.setAction("android.test.TEST_ACTION");
        //需要添加category  不写时，默认是default方法 android.intent.category.DEFAULT
        intent.addCategory("android.TEST_CATEGORY");
        //启动跳转
        startActivity(intent);

    }
}